package com.cqc.aiyagril2.module.splash;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.cqc.aiyagril2.R;
import com.cqc.aiyagril2.base.BaseActivity;
import com.cqc.aiyagril2.config.ConstantsImageUrl;
import com.cqc.aiyagril2.module.home.HomeActivity;
import com.cqc.aiyagril2.utils.CommonUtil;

import java.util.Random;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by ${cqc} on 2018/1/14.
 * 欢迎
 */

public class SplashActivity extends BaseActivity {
    @BindView(R.id.iv_splash)
    ImageView ivSplash;
    @BindView(R.id.tv_next)
    TextView tvNext;

    @Override
    public int getLayoutResId() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        int i = new Random().nextInt(ConstantsImageUrl.TRANSITION_URLS.length);
        Glide.with(this).load(ConstantsImageUrl.TRANSITION_URLS[i])
                .placeholder(R.mipmap.img_transition_default)
                .error(R.mipmap.img_transition_default)
                .into(ivSplash);

        CommonUtil.runOnUIThreadDelayed(new Runnable() {
            @Override
            public void run() {
                Intent intent = new Intent(context, HomeActivity.class);
                toNextActivitySlide(intent);
                SplashActivity.this.finish();
            }
        }, 2000);
    }

    @Override
    protected void initData() {

    }


    @OnClick(R.id.tv_next)
    public void onViewClicked() {
        showToast("下一步");
    }
}
